﻿using System;
using com.yoozoo.gta.Extension.UGUI.ScreenOrientationEx;
using UnityEngine;
using UnityEngine.UI;
using Yoozoo.UI.YGUI;

namespace com.yoozoo.gta.Extension.UGUI.ScreenOrientation.Adapter
{
    [Serializable]
    public class ScrollRectAdaptConfig
    {
        public bool isHorizontal;
        public bool isVertical;
        
        //重写Equals方法
        public override bool Equals(object obj) {
            if (obj == null) {
                return false;
            }

            ScrollRectAdaptConfig other = (ScrollRectAdaptConfig)obj;
            // Compare isHorizontal properties
            if (isHorizontal != other.isHorizontal) {
                return false;
            }
            // Compare isVertical properties
            if (isVertical != other.isVertical) {
                return false;
            }

            return true;
        }
        //重写GetHashCode方法
        public override int GetHashCode() {
            return base.GetHashCode();
        }
    }
    [DisallowMultipleComponent]
    public class ScrollRectAdapter: AdaptBase<ScrollRectAdaptConfig, ScrollRect>
    {
        public override int Order => (int)AdapterExecuteOrder.ListView; 
        protected override void CopyProperty(ScrollRectAdaptConfig config) {
            base.CopyProperty(config);
            config.isHorizontal = mComponent.horizontal;
            config.isVertical = mComponent.vertical;
            
        }

        protected override void ApplyConfig(ScrollRectAdaptConfig config) {
            base.ApplyConfig(config);
            mComponent.horizontal = config.isHorizontal;
            mComponent.vertical = config.isVertical;
        }
    }


}